package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBC {
        public static final String DRIVER ="com.mysql.cj.jdbc.Driver";
        public static final String URL="jdbc:mysql://localhost:3306/BMS?serverTimezone=GMT%2B8";
        public static final String USER="root";
        public static final String PASSWORD="root";

        Connection conn =null;
        public JDBC(){

            try{
                Class.forName(DRIVER);
            }catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

            try{
                conn= DriverManager.getConnection(URL,USER,PASSWORD);
            }catch (SQLException e) {
                e.printStackTrace();
            }
        }
        public Connection getConnection(){
            return this.conn;
        }

        public void close(){
            if(this.conn!=null){
                try{
                    this.conn.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }

    }